package main

import (
	"fmt"
	"time"
)
/*
通过通信共享内存
通信工具为 channel
 */

var ch = make(chan string, 10)

func download(url string) {
	fmt.Println("开始下载此页面：", url)
	time.Sleep(time.Second)
	ch <- url // url 传输给信道
}

func main() {
	startTime := time.Now()

	//fmt.Println(string(29))
	fmt.Println(string(0 + '0'))
	for i := 0; i < 10; i++ {

		go download("a.com/" + string(i + '0'))

	}
	for i := 0; i < 10; i++ {
		msg := <-ch
		fmt.Println(msg)

	}
	fmt.Println("抓取完毕")
	fmt.Println(time.Since(startTime))

}
